<?php

/**
 * Created by PhpStorm.
 * User: allen_ios
 * Date: 16/11/30
 * Time: 下午4:27
 */
class CallDoorCtrlInterf extends BaseInterf implements IcallDoorCtrlInterf
{
    /**
     * 反控开门
     */
    public function doControl($controlType, $doorId)
    {
        $sessionId = BaseInterf::getLoginSessId();
        $params = array(
            'sessionId' => $sessionId,
            'controlType' => $controlType,
            'doorId' => $doorId
        );

        $res = BaseInterf::callInter('doControl', $params);
        wLog('sessionId:' . $sessionId, 'doorctrl');
        wLog('doDoorctrl-res:'.var_export($res,true), 'doorctrl');

        if(!$res){
            return array(false, '用户会话不存在！');
        }
        if($res['head']['errorCode'] != '0'){
            switch($res['head']['errorCode']){
                case '60001':
                    return array(false, '门禁点参数错误！'); //提示信息
                    break;
                case '60002':
                    return array(false, '当前用户无此门禁点的反控操作权限！'); //提示信息
                    break;
                case '60003':
                    return array(false, '未配置DAG服务器或DAG服务器不在线！');
                    break;
                case '60004':
                    return array(false, 'DAG服务器不在线或门禁主机反控失败！');
                    break;
            }
        }
        return array(true, '');
    }


}